﻿Imports Janus.Windows.GridEX

Module Utility

    Private LarghezzaDefault As Integer = 1024
    Private AltezzaDefault As Integer = 768
    Public Function FormattaTesto(Titolo As String) As String
        Dim versione As String

        versione = Application.ProductVersion

        FormattaTesto = Titolo & " " & versione.Substring(0, versione.Length - 2)
    End Function

    Public Function Dimensioni() As System.Drawing.Size

        If System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width < LarghezzaDefault Or System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom() < AltezzaDefault Then
            Dimensioni = New Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom())
        Else
            Dimensioni = New Size(LarghezzaDefault, AltezzaDefault)
        End If

    End Function

    Public Function DimensioniMonitor() As System.Drawing.Size
        DimensioniMonitor = New Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom() - 40)
    End Function


    Public Sub GrideExSetup(ByRef Gridex As Janus.Windows.GridEX.GridEX, ByVal MyForm As Form)

        Dim DimGrid As New System.Drawing.Size
        Dim FontGrid As New System.Drawing.Font("Calibri", 8.25)




        DimGrid.Height = MyForm.Size.Height - (Gridex.Location.Y + 10)
        DimGrid.Width = MyForm.Size.Width - (Gridex.Location.X + 10)

        Gridex.Size = DimGrid
        Gridex.Font = FontGrid
        Gridex.FilterMode = FilterMode.Automatic
        Gridex.FilterRowButtonStyle = FilterRowButtonStyle.ConditionOperatorDropDown
        Gridex.ShowErrors = False
        Gridex.ColumnAutoResize = True
        Gridex.GroupTotals = GroupTotals.Always
        Gridex.GroupMode = GroupMode.Expanded
        Gridex.AllowEdit = InheritableBoolean.True
        Gridex.EditMode = EditMode.EditOn
        Gridex.SaveSettings = True
        Gridex.VisualStyle = VisualStyle.Office2003
        Gridex.AlternatingColors = True

        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionBeginsWith) = "Inizia Con"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionClear) = "Cancella"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionContains) = "Contiene"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionEndsWith) = "Finisce Con"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionEqual) = "Uguale A"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionGreaterThan) = "Maggiore Di"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionGreaterThanOrEqual) = "Maggiore o Uguale Di"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionIsEmpty) = "Vuoto"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionLessThan) = "Minore Di"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionLessThanOrEqual) = "Minore o Uguale Di"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionNotContains) = "Non Contiene"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionNotEqual) = "Diverso Da"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.FilterRowConditionNotIsEmpty) = "Non Vuoto"
        Gridex.BuiltInTexts.Item(GridEXBuiltInText.GroupByBoxInfo) = "Trascina qui un'intestazione di colonna"



    End Sub

    Public Sub MessaggioErrore(Messaggio As String, exc As Exception, Applicazione As String)

        MessageBox.Show(Messaggio + vbCrLf + exc.Message, Applicazione, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    End Sub

    Public Sub FCSlaveSetup(ByRef Gridex As Janus.Windows.GridEX.GridEX)
        Dim dbColumn As GridEXColumn
        Dim fc As GridEXFormatCondition
        'Imposta la format condition per le righe che provengono da SLAVE

        dbColumn = Gridex.RootTable.Columns("db")
        If Not (dbColumn Is Nothing) Then
            fc = New GridEXFormatCondition(dbColumn, ConditionOperator.Equal, "SLAVE")
            fc.FormatStyle.BackColor = Color.Yellow
            Gridex.RootTable.FormatConditions.Add(fc)
        Else
            MsgBox("La colonna db non fa parte del Grid")
        End If
    End Sub
End Module
